package cn.com.wdjedu.androidapp.wjeduandroid.ui.videoshow.adpter;

import android.content.Context;

import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

import cn.com.wdjedu.androidapp.wjeduandroid.R;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.video.videoBean;
import cn.com.wdjedu.androidapp.wjeduandroid.support.lib.view.MyGridView;

/**
 *   章节适配器
 */

public class ChapterFragmentAdapter extends CommonAdapter<videoBean> {

    private String UnitName[];
    private SubChapterFragmentAdapter subAdapter;

    public ChapterFragmentAdapter(Context context, int layoutId, List<videoBean> datas) {
        super(context, layoutId, datas);
    }


    @Override
    protected void convert(ViewHolder viewHolder, videoBean item, int position) {
        viewHolder.setText(R.id.item_chapter_num,item.getUnitInfo().getName());
//        switch (item.getData().getLists().get(position).getUnit()){
//            case 1: UnitName="Core Jave/Java核心知识"; break;
//            case 2: UnitName="Java基本方法"; break;
//            case 3: UnitName="Java数据处理"; break;
//            case 4: UnitName="继承/重载/抽象类/接口/可视化编程"; break;
//            case 5: UnitName="异常与集合"; break;
//            case 6: UnitName="文件与流"; break;
//            case 7: UnitName="线程"; break;
//            case 8: UnitName="网络编程"; break;
//            case 9: UnitName="Java进阶"; break;
//            case 10: UnitName="JDBC数据库编程"; break;
//            case 11: UnitName="JavaWeb编程/Servlet"; break;
//            case 12: UnitName="Struts框架编程"; break;
//        }
        UnitName=item.getUnitInfo().getTitle().split("-");
        viewHolder.setText(R.id.item_chapter_name,UnitName[0]);
        MyGridView mycourselist = viewHolder.getView(R.id.item_mylistview);

        subAdapter = new SubChapterFragmentAdapter(mContext,R.layout.sub_item_viewshow_chapter,item.getData().getLists());
        mycourselist.setAdapter(subAdapter);

    }


//    private SubChapterFragmentAdapter adapter;
//    private List<ChaterBean.SubChater> lists;
//    public ChapterFragmentAdapter(Context context, int layoutId, List<ChaterBean> datas) {
//        super(context, layoutId, datas);
//        lists=new ArrayList<>();
//        adapter=new SubChapterFragmentAdapter(mContext,R.layout.sub_item_viewshow_chapter,lists);
//    }
//
//    @Override
//    protected void convert(ViewHolder viewHolder, ChaterBean item, int position) {
//        viewHolder.setText(R.id.item_chapter_num,item.getChater());
//        viewHolder.setText(R.id.item_chapter_name,item.getChaterDetails());
//        MyListView myListView=viewHolder.getView(R.id.item_mylistview);
//        lists.clear();
//        lists.addAll(item.getList());
//        myListView.setAdapter(adapter);
//        adapter.notifyDataSetChanged();
//    }
}
